package com.henghai.zhenxuan.data.bean;

import androidx.annotation.Nullable;

import okhttp3.Headers;

public class HttpBean<T> {
    /** 响应头 */
    @Nullable
    private Headers responseHeaders;
    /** 返回码 */
    private int code;
    /** 提示语 */
    private String msg;
    /** 数据 */
    @Nullable
    private T data;
    public void setResponseHeaders(@Nullable Headers responseHeaders) {
        this.responseHeaders = responseHeaders;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Nullable
    public T getData() {
        return data;
    }
    public boolean isRequestSuccess() {

        return code == 200;
    }
    /**
     * 是否 Token 失效
     */
    public boolean isTokenInvalidation() {
        return code == 1001 || code == 401;
    }

    @Override
    public String toString() {
        return "HttpBean{" +
                "responseHeaders=" + responseHeaders +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
